package g.beny.framework.exception;

import java.io.PrintWriter;
import java.io.StringWriter;

/**
 * 异常处理
 * @author gson
 *
 */
public abstract class BenyException extends Exception {
	private static final long serialVersionUID = 1L;
	/**
	 * 异常编码
	 */
	private int code;
	/**
	 * 异常错误描述
	 */
	private Object msg;
	
	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}
	
	public Object getMsg() {
		return msg;
	}

	public void setMsg(Object msg) {
		this.msg = msg;
	}

	/**
	 * 桟信息
	 */
	public String getStringStackTrace() {
		StringWriter sw = new StringWriter();
		PrintWriter pw = new PrintWriter(sw);
		printStackTrace(pw);
		return sw.toString().replaceAll("\\\r\\\n", "<br/>").replaceFirst("<br/>", "<blockquote>") + "</blockquote>";
	}
	
	/**
	 * 异常类型
	 */
	public String getType() {
		return "异常类型";
	}
}
